<?php
namespace Admin\Controller;
use Think\Controller;
//供应商控制器 by chenheyou
class SupplierController extends Controller {
	
	//2016.4.14 by chenheyou
    public function index(){
        $object=M('Supplier');
        import('ORG.Util.Page');			//Page类的引入
        $count=$object->where($where)->count(); //获取符合条件的数据总数count
		$Page=new \Org\Util\Page($count, 10);			//实例化page类，传入数据总数和每页显示10条内容
		$show=$Page->show();
		$list=$object->where($where)->limit($Page->firstRow.','.$Page->listRows)->select();
        $this->assign('list',$list);
        $this->assign("page",$show);
        $this->display();
    }
	
	//2016.4.14 by chenheyou
    public function editUI(){
		if(I('get.id')){
			$this->assign('object',M('Supplier')->where('id='.I('get.id'))->find());
		}
        $this->display('editUI');
    }
	
	//2016.4.14 by chenheyou
    public function editOperation(){
		$Object = M("Supplier");   
		$Object->create();
		$id = I('post.id');
		if($id){
			//修改
			if($Object->save()){
				$this->success('修改成功',U('index'));
			}else{
				dump($Object->_sql());
				$this->error('修改失败');
			}
		}else{
			//增加
			if($Object->add()){
				$this->success('添加成功',U('index'));
			}else{
				dump($Object->_sql());
				$this->error('添加失败');
			}
		}
    }
	
	//2016.4.14 by chenheyou
    public function removeOperation(){
		// 获取表单的POST数据
		$Object = M("Supplier"); // 实例化User对象
		if($Object->delete(I('get.id'))){
			$this->success('删除成功',U('index'));
		}else{
			dump($Object->_sql());
			$this->error('删除失败');
		}
    }
	
	//2016.4.14 by chenheyou
    public function infoUI(){
        $this->display('info');
    }
}